Snippets Collections
private boolean oneQueenPerRow() {
    int foundQueens;
    for (int i = 0; i < board.length; i++) {
        foundQueens = 0;//each loop is a checked row
        for (int j = 0; j < board.length; j++) {
            if (board[i][j] == QUEEN)
                foundQueens++;
        }
        if (foundQueens > 1) return false;
    }
    return true;
}
star

Wed Apr 01 2020 08:24:35 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/60963813/how-do-you-check-a-row-in-a-2d-char-array-for-a-specific-element-and-then-count

#java #java #2dchar array

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension